#pragma once
#include "CCollection.h"

class CDependencyObject;
class CCollection;

class CDOCollection :
	public CCollection
{

protected: 
	CDOCollection();
public: 
	virtual ~CDOCollection();
	static HRESULT Create(CDependencyObject * * ppObject, CREATEPARAMETERS * pCreate);
	virtual XBOOL ContainsDependencyObject();
	CDependencyObject * GetParentForItems();
protected: 
	void OnCollectionChangeHelper();
	HRESULT ChangeParent(CDependencyObject * pChild, CDependencyObject * pNewParent, CDependencyObject * pOldParent, XBOOL fPublic);
private: 
	HRESULT SetChildParent(CDependencyObject * pChild, CDependencyObject * pParent, CDependencyObject * pOldParent, XBOOL fPublic);
	virtual void ReleaseItem(void * pItem);
	HRESULT VerifyParentIsThisCollection(CDependencyObject * pChild);
protected: 
	virtual XBOOL ShouldBeParentToItems();
	virtual XBOOL ShouldParentBePublic();
	virtual XBOOL ShouldProcessEnterLeave();
	virtual XBOOL ShouldEnsureNameResolution();
	virtual XBOOL ShouldKeepPeerReference();
	virtual XBOOL CanEnterImpl(CDependencyObject * pNamescopeOwner);
	virtual HRESULT EnterImpl(CDependencyObject * pNamescopeOwner, struct EnterParams params);
	virtual HRESULT LeaveImpl(CDependencyObject * pNamescopeOwner, struct LeaveParams params);
	virtual CDependencyObject * GetNamescopeParent();
	virtual XBOOL CanProcessEnterLeave();
	virtual HRESULT ChildEnter(CDependencyObject * pChild, CDependencyObject * pNamescopeOwner, struct EnterParams params, XBOOL fCanProcessEnterLeave);
	virtual HRESULT ChildLeave(CDependencyObject * pChild, CDependencyObject * pNamescopeOwner, struct LeaveParams params, XBOOL fCanProcessEnterLeave);
public: 
	virtual bool IsLeaving();
	virtual HRESULT PropagateOwnerInfo(CDependencyObject * pOwner, CDependencyObject * pOldOwner);
	virtual HRESULT OnAddToCollection(const CValue & pDO);
	virtual HRESULT OnAddToCollection(CDependencyObject * pDO);
	virtual HRESULT OnRemoveFromCollection(const CValue & pDO, XINT32 iPreviousIndex);
	virtual HRESULT OnRemoveFromCollection(CDependencyObject * pDO, XINT32 iPreviousIndex);
	virtual HRESULT OnClear();
	virtual HRESULT Append(CDependencyObject * pObject, XUINT32 * pnIndex);
	virtual HRESULT Append(CValue & pObject, XUINT32 * pnIndex);
	virtual HRESULT AppendImpl(CDependencyObject * pObject, XUINT32 * pnIndex);
	virtual HRESULT Insert(XUINT32 nIndex, CDependencyObject * pObject);
	virtual HRESULT Insert(XUINT32 nIndex, CValue & pObject);
	virtual HRESULT InsertImpl(XUINT32 nIndex, CDependencyObject * pObject);
	virtual CDependencyObject * Remove(CDependencyObject * pObject);
	virtual void * Remove(void * pObject);
	virtual void * RemoveAt(XUINT32 nIndex);
	virtual CDependencyObject * RemoveAtImpl(XUINT32 nIndex);
	virtual void * GetItem(XUINT32 nIndex);
	virtual CDependencyObject * GetItemImpl(XUINT32 nIndex);
	virtual CDependencyObject * GetItemAtFastImpl(XUINT32 index, CDependencyObject * * ppDO);
	virtual CDependencyObject * GetItemDO(XUINT32 nIndex);
	virtual HRESULT IndexOf(CDependencyObject * pDO, XINT32 * pIndex);
	virtual HRESULT IndexOf(CValue & pDO, XINT32 * pIndex);
	virtual HRESULT IndexOfImpl(CDependencyObject * pDO, XINT32 * pIndex);
	virtual HRESULT Move(XINT32 nIndex, XINT32 nPosition);
	virtual XINT32 IsObjectAssociated(CDependencyObject * pObject);
	virtual HRESULT CycleCheck(CDependencyObject * pObject);
	virtual XBOOL ShouldExplicitReleaseOnRemove();
	virtual XBOOL ShouldAssociateChildren(CDependencyObject * __formal);
protected: 
	virtual HRESULT Neat(XINT32 bBreak);
	virtual HRESULT NeatImpl();
	virtual HRESULT Tidy(XINT32 bBreak);
	virtual HRESULT ValidateItem(CDependencyObject * pObject);
	virtual XUINT8 * GetFlattened();
	virtual void SetFlattened(XUINT8 * pFlattened);
	virtual XUINT8 * * GetBlocks();
	virtual void SetBlocks(XUINT8 * * ppBlocks);
	struct Block * * m_ppBlock;
	CDependencyObject * * m_pFlattened;
	XBOOL m_fIsLeaving;
	XBOOL m_fIsProcessingNeat;
};

